<?php
class UUID
{
    protected $_binary;

    protected $_hex;

    /**
     * Represents a UUID based upon a given hexadecimal string, binary data, or
     * generated
     * using the current time, node (MAC Address), and clock sequence.
     *
     * @param string hex
     * @param binary binary
     * @param binary $node
     * @param binary $clockSeq
     */
    public function __construct($hex = NULL, $binary = NULL, $node = NULL, $clockSeq = NULL)
    {
        // 0x01b21dd213814000 is the number of 100-ns intervals between the
        // UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
        $kindId = array_search($kind, self::$_kinds);

        if (!$kindId)
        {
            throw new Exception("Invalid Kind");
        }

        $time = microtime(1);
        $this -> _binary = pack("NnnN", $time, $time * 10000>>32, Nuo::getKindId($kind), mt_rand(0, 0xFFFFFF));
        $this -> _hex = unpack("H*hex", $this -> _binary);

    }

    public function getBinary()
    {
        return $this -> _binary;
    }

    public function getHex()
    {
        return $this -> _hex;
    }

}
